package com.xiao.androidcompose01

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import cafe.adriel.voyager.navigator.Navigator
import cafe.adriel.voyager.transitions.SlideTransition
import com.xiao.androidcompose01.api.data.AccountData
import com.xiao.androidcompose01.screen.LoginScreen
import com.xiao.androidcompose01.ui.theme.AndroidCompose01Theme
import org.koin.compose.KoinContext

val LocalInnerPadding = staticCompositionLocalOf<PaddingValues?> { null }

val LocalAccountData = staticCompositionLocalOf<AccountData> { error("用户未登录") }
class MainActivity : ComponentActivity() {
   override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      enableEdgeToEdge()
      setContent {
         AndroidCompose01Theme {
            Navigator(LoginScreen()) { navigator ->
               Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
                  CompositionLocalProvider(LocalInnerPadding provides innerPadding) {
                     SlideTransition(navigator, modifier = Modifier)
                  }
                  
               }
               
            }
            
         }
      }
   }
}

@Composable
fun Greeting(name: String, modifier: Modifier = Modifier) {
   Text(
      text = "Hello $name!",
      modifier = modifier
   )
}

@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
   AndroidCompose01Theme {
      Greeting("Android")
   }
}